<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
    String path = request.getContextPath(); 
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+path+ "/"; 
     
%>
<!DOCTYPE HTML>
<html>
<head>
	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	<title>修改密码</title>
	
			<!-- basic styles -->
		<link rel="stylesheet" type="text/css" href="css/xcConfirm.css"/>
		<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" />
		<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
		<link rel="stylesheet" href="bootstrap-fileinput-master/css/fileinput.min.css">
		<link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.min.css" />
		<link rel="stylesheet" href="css/bootstrap-datetimepicker.css" />
		<link rel="stylesheet" href="bootstrap-table/dist/bootstrap-table.css">
		
		<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    	<link rel="stylesheet" href="css/font.css">
    
    	<link rel="stylesheet" href="./css/x-admin.css" media="all">
		 <!-- ace styles -->
		 <style type="text/css">
        #panel {
            position: absolute;
            background-color: white;
            max-height: 90%;
            overflow-y: auto;
            top: 10px;
            right: 10px;
            width: 280px;
        }
        .td1{
			float:left;
			width:50px;
			display: block; 
			valign:middle;
		}
		.td2{
			float:left;
			width:200px;
			display: block; 
			valign:middle;
		}
		.td3{
			float:left;
			width:660px;
			display: block; 
			valign:middle;
		}
    </style>
	
</head>
<body style="padding: 40px 50px">
	<div class="main-content" style="margin-left: 0px">
		<div class="row base-margin" id="query">
  		<div   class="form-horizontal" role="form">

			  <div class="form-group">
			    <label for="firstname" class="col-sm-2 control-label">原密码:</label>
			    <div class="col-sm-3">
			      <input type="password" class="form-control" id="oldPassword" name="oldPassword"   placeholder="请输入原密码"/>
			    </div>
			  </div>
			  
			  <div class="form-group">
			    <label for="firstname" class="col-sm-2 control-label">新密码:</label>
			    <div class="col-sm-3">
			      <input type="password" class="form-control" id="newPassword" name="newPassword"   placeholder="请输入新密码"/>
			    </div>
			  </div>
			  
			  <div class="form-group">
			    <label for="firstname" class="col-sm-2 control-label">确认密码:</label>
			    <div class="col-sm-3">
			      <input type="password" class="form-control" id="comfirmPassword" name="comfirmPassword"   placeholder="请输入确认密码"/>
			    </div>
			  </div>
			  
			  
		     	<div class="form-group" style="padding-left: 30%">
		        	<button type="submit"   onclick="save()"  class="btn btn-info" >保存</button>
		        	<button type="reset"    onclick="cancel()"  class="btn btn-info" >取消 </button>
		     	</div>
          	</div>
          </div>
	</div>
	<!-- 加载需要的js -->
	<script src="js/jquery-3.2.1.min.js"></script>
	<script src="js/common2.js"></script>
	<script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	<script src="js/jquery-bootstrap-pagination.js"></script>
	<script src="js/qunit-1.11.0.js"></script>
	<script src="js/bootstrap-datetimepicker.js"></script>
	<script src="js/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="js/xcConfirm.js" type="text/javascript" charset="utf-8"></script>
    <script src="bootstrap-fileinput-master/js/fileinput.min.js"></script>
	<script src="bootstrap-fileinput-master/js/locales/zh.js"></script>
	<script src="bootstrap-table/dist/bootstrap-table.min.js"></script>
	<script src="bootstrap-table/dist/locale/bootstrap-table-zh-CN.min.js"></script>
	
	<script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script src="./js/x-layui.js" charset="utf-8"></script>
  
	<script type="text/javascript" charset="utf-8">
	
	 layui.use(['form','layer','upload'], function(){
         $ = layui.jquery;
       var form = layui.form()
       ,layer = layui.layer;
       });
	     
	    function save(){
	    	var oldPassword =	$("#oldPassword").val();
  		   	 if(oldPassword == null||oldPassword=="") {
  		   		layer.msg('原密码不能为空!',{icon:2,time:2000});
  				  return ;
  		   	 }
  		   var newPassword =	$("#newPassword").val();
  		 	if(newPassword == null||newPassword=="") {
				layer.msg('新密码不能为空!',{icon:2,time:2000});
				  return ;
		   	 }
		   	 
  		 	var comfirmPassword =	$("#comfirmPassword").val();
  		 	if(comfirmPassword == null||comfirmPassword=="") {
				layer.msg('确认密码不能为空!',{icon:2,time:2000});
				  return ;
		   	 }
			 
   	  		
			 var  data = {"oldPwd":oldPassword,"newPwd":newPassword,"againNewPwd":comfirmPassword}
	         $.ajax({
	             type: "post",
	             url: "sysUser/updatePwd",
	             data: JSON.stringify(data),
   	             contentType:"application/json;charset=UTF-8", 
   	             dataType:"json",
   	             success: function(data){    
   	            	if(data.code==200){
   	    	           	layer.alert("修改成功,请重新登录", {icon: 6},function () {
   	    	           	window.location.href="login.jsp";
   	 	                });    
   	 	       		}else{
   	 	    	      	var txt=data.msg;
   	 	    		layer.alert(txt, {icon: 6},function () {
   	 	    		location.reload();
   	 	                });  
   	 	      	       }
   	             }
	         });  
	         
			}
	    
	    	function cancel(){
   		   	
	    		window.location.href="index.jsp";
	   	         
	   			}
	   
	</script>
</body>
</html>


